﻿<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">

<style type="text/css">

	.l{float:left;}
	.r{float:right;}

	#dvSrc
	{
		width:400px;
		height:400px;
		border:solid 1px red;
		background-color:Yellow;	
	}
	
	#dvProxy
	{
		width:400px;
		height:400px;
		border:solid 1px red;
		background-color:Green;
	}

	.ms_box
	{
		float:left;
		width: 800px;
		height: 800px;	
	}

	.ms_fundcompany_ayf
	{
		background-image:url('http://www.csri.or.th/sites/default/files/AYF.jpg?1265276964');	
		width:160px;
		height:160px;
		border:solid 1px red;
	}
	
	.ms_fundcompany_mfc
	{
		background-image:url('http://www.mfcfund.com/php/th/images/news172_2.jpg');	
		width:160px;
		height:160px;
		border:solid 1px red;
	}
	
	#pnlBasic,#pnlAdvance
	{
		height:300px;	
	}
	
	.ms_box
	{
		background-color:White;
		width:800px;
		height:600px;
		padding:6px 6px 6px 6px;	
	}
	
	.ms_lbl
	{
		float:left;
		font-weight:bolder;
		width:250px;
		height:34px;	
		margin-left:13px;
	}
	
	
	.ms_lbl_adv2,.ms_lbl_adv
	{
		float:left;
		font-weight:bolder;
		width:250px;
		/*height:34px;*/	
	
	}
	
	.ms_ctrl
	{
		float:left;	
		height:34px;
	}
	
	.ms_ctrl_adv,.ms_ctrl_adv
	{
		float:left;	
		/*height:34px;*/
	
	}
	
	.clearfix:after {
	  clear:both;
	  content:".";
	  display:block;
	  height:0;
	  line-height:0;
	  visibility:hidden;
	}
	
	#MainDiv
	{
		display:none;	
	}
	

	.ReturnNegative
	{
		color:red;
	}

	.ReturnPositive
	{
		color:green;
	}
	#accordion-resizer1,#accordion-resizer2 {
        padding: 10px;
        width: 375px;
        height: 220px;
    }
    
    .proxy-main-container
    {
		width:850px;	
    }
    

    
    .ui-widget-content
    {
		height:auto !important;
    }
    
    #ddlAdvFundCompany,#ddlAdvAssetType,#ddlAdvMorningstarCategory,#ddlAdvAllAIMC
    {
		width:300px;	
    }
    
	div.compare {
		background-image:url(/img/icons/actionmenu/compare.gif);
		background-repeat:no-repeat;
		padding-left:20px;
		padding-right:5px;
		
		margin-left:20px;
	}
	div.compare:hover {
		background-image:url(/img/icons/actionmenu/compare_rollover.gif);
		background-repeat:no-repeat;
		padding-left:20px;
		padding-right:5px;
		
		margin-left:20px;
	}

	div.portfolio {
		background-image:url(/img/icons/actionmenu/add-portfolio.gif);
		background-repeat:no-repeat;
		padding-left:20px;
		padding-right:5px;
		
		margin-left:20px;
	}
	div.portfolio:hover {
		background-image:url(/img/icons/actionmenu/add-portfolio_rollover.gif);
		background-repeat:no-repeat;
		padding-left:20px;
		padding-right:5px;
		
		margin-left:20px;
	}

	div.xray {
		background-image:url(/img/icons/actionmenu/x-ray.gif);
		background-repeat:no-repeat;
		padding-left:20px;
		padding-right:5px;
		
		margin-left:20px;
	}
	div.xray:hover {
		background-image:url(/img/icons/actionmenu/x-ray_rollover.gif);
		background-repeat:no-repeat;
		padding-left:20px;
		padding-right:5px;
		
		margin-left:20px;
	}

	div.deselect {
		background-image:url(/img/icons/actionmenu/deselect.gif);
		background-repeat:no-repeat;
		padding-left:20px;
		padding-right:5px;
		
		margin-left:20px;
	}
	div.deselect:hover {
		background-image:url(/img/icons/actionmenu/deselect_rollover.gif);
		background-repeat:no-repeat;
		padding-left:20px;
		padding-right:5px;
		
		margin-left:20px;
	}

    
    
</style>

</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

		

		<h1 onclick='$("#MainDiv").toggle();'>
			<b>Fund Quickrank</b>
		</h1>

		<div id="example" class='ui-widget proxy-main-container' style='height:300px; '>
		 <ul>
			 <li><a href="#tabs-1"><span>Basic Search</span></a></li>
			 <li><a href="#tabs-2"><span>Advanced Search</span></a></li>
			 
		 </ul>

		<div id="tabs-1" class="ui-widget">
		
			<div class='ui-widget-content ui-helper-clearfix' style='height:230px;'>
			
				<br />
				<div class='clearfix'></div>
				<div class='ms_lbl'>
					Universe
				</div>
				<div class='ms_ctrl'>
					<select id='ddlProxyUniverse'
							ms_proxy_mapping='{sourceId:"#ctl00_ContentPlaceHolder1_aFundScreenerResultControl_ddlUniverse",sourceAttr:"val",proxyAttr:"val"}'>
					</select>
				</div>

				<div class='clearfix'></div>
				<div class='ms_lbl'>
					Fund Company
				</div>
				<div class='ms_ctrl'>
					<select id='ddlProxyFundCompany'
							ms_proxy_mapping='{sourceId:"#ctl00_ContentPlaceHolder1_aFundScreenerResultControl_ddlCompany",sourceAttr:"val",proxyAttr:"val"}'>
					</select>
				</div>

				<div class='clearfix'></div>
				<div class='ms_lbl'>
					AIMC Board Categories
				</div>
				<div class='ms_ctrl'>
					<select id='ddlProxyAIMCBoard'
							ms_proxy_mapping='{sourceId:"#ctl00_ContentPlaceHolder1_aFundScreenerResultControl_ddlCategory",sourceAttr:"val",proxyAttr:"val"}'>
						</select>
				</div>

				<div class='clearfix'></div>
				<div class='ms_lbl'>
					Fund Type
				</div>
				<div class='ms_ctrl'>
					<select id='ddlProxyFundType'
							ms_proxy_mapping='{sourceId:"#ctl00_ContentPlaceHolder1_aFundQuickrankControl_ddlBroadCategoryType",sourceAttr:"val",proxyAttr:"val"}'>
					</select>
				</div>

				<div class='clearfix'></div>
				<div class='ms_lbl'>
					Fund Name
				</div>
				<div class='ms_ctrl'>
					<input	id='txtProxyFundname' 
							ms_proxy_mapping='{sourceId:"#ctl00_ContentPlaceHolder1_aFundScreenerResultControl_txtSearchKey",sourceAttr:"val",proxyAttr:"val"}'
							type='text' />	
				</div>

				<div class='clearfix'></div>
				<div class='ms_lbl'>
					&nbsp;
				</div>
				<div class='ms_ctrl'>
					<button id="btnProxyFilter" 
							type='button'
							class="ui-button ui-widget ui-state-default ui-button-text-only" 
							role="button" aria-disabled="false"
							ms_proxy_mapping="{sourceId:'#ctl00_ContentPlaceHolder1_aFundScreenerResultControl_btnSearch',custom : ms_screener.filter }" >
							<span class="ui-button-text">Filter</span>
					</button>
				</div>



				

			</div>
			
		</div>

		<div id="tabs-2" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-helper-clearfix">
			
			<!--left panel-->
	

				
				<div id="dvProxyFundType" style='float:left; width:380px;'>
					
					<h3>
						Fund Type
						<button id='btnAdvFilter'></button>
					</h3>
					<div>
					<!--start accordian-->
						<div class='l'>
						
						
						
							<div class='clearfix'></div>
							<div class='ms_lbl_adv'>
								Fund Companiey
							</div>
							<div class='clearfix'></div>
							<div class='ms_ctrl_adv'>
								<select id='ddlAdvCompany'>
									<option value=''>All Companies</option>
								</select>
							</div>

							<br />
							<br />
							<div class='clearfix'></div>
							<div class='ms_lbl_adv'>
								Asset Type
							</div>
							<div class='clearfix'></div>
							<div class='ms_ctrl_adv'>
								<select id='ddlAdvCategoryType'>
									<option value=''>All Asset Type</option>
								</select>
							</div>

							<br />
							<br />
							<div class='clearfix'></div>
							<div class='ms_lbl_adv'>
								Morningstar Category
							</div>
							<div class='clearfix'></div>
							<div class='ms_ctrl_adv'>
								<select id='ddlAdvCategory'>
									<option value=''>All Morningstar Categories</option>
								</select>
							</div>

							<br />
							<br />
							<div class='clearfix'></div>
							<div class='ms_lbl_adv'>
								AIMC Classification
							</div>
							<div class='clearfix'></div>
							<div class='ms_ctrl_adv'>
								<select id='ddlAdvAllAIMC'>
									<option value=''>All AIMC Category</option>
								</select>
							</div>

							<br />
							<br />
							<div class='clearfix'></div>
							<div class='ms_lbl_adv'>
								Dividend Policy
							</div>
							<div class='clearfix'></div>
							<div class='ms_ctrl_adv'>
								<input value='1|0|0' name='rbInOrAcc' id='rbInOrAccAll' type='radio' checked='checked' /> <label for='rbInOrAccAll'>All</label>
								<input value='0|1|0' name='rbInOrAcc' id='rbInOrAccPaid' type='radio'  /> <label for='rbInOrAccPaid'>Paid</label>
								<input value='0|0|1' name='rbInOrAcc' id='rbInOrAccRetain' type='radio'  /> <label for='rbInOrAccRetain'>Retain</label> 
							</div>

							<br />
							<br />
							<div class='clearfix'></div>
							<div class='ms_lbl_adv'>
								Fund of Funds
							</div>
							<div class='clearfix'></div>
							<div class='ms_ctrl_adv'>
								<input value='1|0|0'  name='rbFundOfFunds' id='rbFundOfFundsAll' type='radio' checked='checked' /> <label for='rbFundOfFundsAll'>All</label>
								<input value='0|1|0'  name='rbFundOfFunds' id='rbFundOfFundsYes' type='radio' /> <label for='rbFundOfFundsYes'>Yes</label>
								<input value='0|0|1'  name='rbFundOfFunds' id='rbFundOfFundsNo' type='radio' /> <label for='rbFundOfFundsNo'>No</label>					
							</div>


							
						
						</div>
					<!--end accordian-->
					</div>

		


				</div>


			

			<!--right panel-->
		
					
				<div id='dvProxyFundPerformanceRisk' style='float:right; width:380px;' >

						<h3>
							Fund Type
						</h3>
						
						<div>
							
							<div class='clearfix'></div>
							<div class='ms_lbl_adv2'>
								Morningstar Rating&trade;
							</div>
							<div class='clearfix'></div>
							<div class='ms_ctrl_adv2'>
								<input id='cbAdvRating5' type='checkbox' /> 
								<label for='cbAdvRating5'><img alt='' src='http://tools.morningstarthailand.com/img/5stars.gif' /></label>
							</div>
							<div class='clearfix'></div>
							<div class='ms_ctrl_adv2'>
								<input id='cbAdvRating4' type='checkbox' /> 
								<label for='cbAdvRating4'><img alt='' src='http://tools.morningstarthailand.com/img/4stars.gif' /></label>
							</div>
							<div class='clearfix'></div>
							<div class='ms_ctrl_adv2'>
								<input id='cbAdvRating3' type='checkbox' /> 
								<label for='cbAdvRating3'><img alt='' src='http://tools.morningstarthailand.com/img/3stars.gif' /></label>
							</div>
							<div class='clearfix'></div>
							<div class='ms_ctrl_adv2'>
								<input id='cbAdvRating2' type='checkbox' /> 
								<label for='cbAdvRating2'><img alt='' src='http://tools.morningstarthailand.com/img/2stars.gif' /></label>
							</div>
							<div class='clearfix'></div>
							<div class='ms_ctrl_adv2'>
								<input id='cbAdvRating1' type='checkbox' /> 
								<label for='cbAdvRating1'><img alt='' src='http://tools.morningstarthailand.com/img/1stars.gif' /></label>
							</div>

							<br />
							<br />
							<hr />
							<div class='clearfix'></div>
							<div class='ms_lbl_adv2'>
								Morningstar Risk (Rel to Cat)
							</div>
							<div  class='ms_ctrl_adv2'>
								<br />
								<div id='radA'>
									<input type="radio" id="cbAdvRisk1" name="cbRisk" /><label for="cbAdvRisk1">Low</label>
									<input type="radio" id="cbAdvRisk2" name="cbRisk" /><label for="cbAdvRisk2">- Avg</label>
									<input type="radio" id="cbAdvRisk3" name="cbRisk" /><label for="cbAdvRisk3">Avg</label>
									<input type="radio" id="cbAdvRisk4" name="cbRisk" /><label for="cbAdvRisk4">+ Avg</label>
									<input type="radio" id="cbAdvRisk5" name="cbRisk" /><label for="cbAdvRisk5">High</label>
								</div>
							</div>


							<br />
							<br />
							<hr />
							<div class='clearfix'></div>
							<div class='ms_lbl_adv2'>
								3 Yr Standard Deviation
							</div>
							<div class='ms_ctrl_adv2'>
								<br />
								<div id='radB'>
								
									<input type="radio" id="rbAdvStdDeviation1" name="radioa" /><label for="rbAdvStdDeviation1">Low</label>
									<input type="radio" id="rbAdvStdDeviation2" name="radioa" /><label for="rbAdvStdDeviation2">Moderate High</label>
									<input type="radio" id="rbAdvStdDeviation3" name="radioa" /><label for="rbAdvStdDeviation3">Avg</label>
								
								</div>


							</div>

							


							<br />
							<br />
							<hr />
							<div class='clearfix'></div>
							<div class='ms_lbl_adv2'>
								3 Yr Standard Deviation
							</div>
							<div class='ms_ctrl_adv2'>
								
								<table>
									<tr>
										<td>YTD</td>
										<td> &gt; </td>
										<td>
											<select id='ddlAdvYTD' match_ctrl='#txtAdvYTD'>
												<option value=''>Please select...</option>
												<option value='CatAvg'>Category Average</option>
												<option value='SpecificValue'>Specific value</option>
											</select>	
										</td>
										<td>
											<input id='txtAdvYTD' type='text' disabled='disabled' style='width:50px;' />
										</td>
									</tr>
									<tr>
										<td>1 Year</td>
										<td> &gt; </td>
										<td>
											<select id='ddlAdv1Yr' match_ctrl='#txtAdv1Yr'>
												<option value=''>Please select...</option>
												<option value='CatAvg'>Category Average</option>
												<option value='SpecificValue'>Specific value</option>
											</select>	
										</td>
										<td>
											<input id='txtAdv1Yr' type='text' disabled='disabled' style='width:50px;' />
										</td>
									</tr>
									<tr>
										<td>3 Year</td>
										<td> &gt; </td>
										<td>
											<select id='ddlAdv3Yr' match_ctrl='#txtAdv3Yr'>
												<option value=''>Please select...</option>
												<option value='CatAvg'>Category Average</option>
												<option value='SpecificValue'>Specific value</option>
											</select>										
										</td>
										<td>
											<input id='txtAdv3Yr' type='text' disabled='disabled' style='width:50px;' />
										</td>
									</tr>
									<tr>
										<td>5 Year</td>
										<td> &gt; </td>
										<td>
											<select id='ddlAdv5Yr' match_ctrl='#txtAdv5Yr'>
												<option value=''>Please select...</option>
												<option value='CatAvg'>Category Average</option>
												<option value='SpecificValue'>Specific value</option>
											</select>									
										</td>
										<td>
											<input id='txtAdv5Yr' type='text' disabled='disabled' style='width:50px;' />
										</td>
									</tr>
									<tr>
										<td>10 Year</td>
										<td> &gt; </td>
										<td>
											<select id='ddlAdv10Yr' match_ctrl='#txtAdv10Yr'>
												<option value=''>Please select...</option>
												<option value='CatAvg'>Category Average</option>
												<option value='SpecificValue'>Specific value</option>
											</select>									
										</td>
										<td>
											<input id='txtAdv10Yr' type='text' disabled='disabled' style='width:50px;' />
										</td>
									</tr>
								</table>

							</div>


						</div>

					</div>


		

			</div>


		</div>




		<br /><br />

		<div class='clearfix'></div>
		<div class="ui-widget proxy-main-container">
		
		
			
				

				<div id='proxyRsTab' class='ui-widget-content'>

					<ul>
						<li><a href="#proxyTabSnapshot">ภาพรวม</a></li>
						<li><a href="#proxyTabShortTerm">ผลตอบแทนระยะสั้น</a></li>
						<li><a href="#proxyTabPerformance">ผลตอบแทนระยะยาว</a></li>
						<li><a href="#proxyTabPortfolio">พอร์ตโฟลิโอ</a></li>
						<li><a href="#proxyTabFeesAndDetails">ค่าธรรมเนียมและอื่นๆ</a></li>
					</ul>
					

					<div id='proxyTabSnapshot' ms_proxy_mapping='{sourceId:"#ctl00_ContentPlaceHolder1_aFundScreenerResultControl_gridResult",custom : ms_engine.template.mainTable}'>
						
						<!--Table Template is here-->

					</div>
					<div id='proxyTabShortTerm'>
					
						 <!--Table Template is here-->
					
					</div>
					<div id='proxyTabPerformance'>
					
						 <!--Table Template is here-->

					</div>
					<div id='proxyTabPortfolio'>
					
						<!--Table Template is here-->
						 
					</div>
					<div id='proxyTabFeesAndDetails'>
					
						 <!--Table Template is here-->

					</div>
					

				</div>
		

		</div>


	
		<div class='clearfix'></div>
		<div class="ui-widget proxy-main-container">
		
				<div class='ui-widget-header'>
					Results : 
				</div>

				<div id='dvResultBox' class='ui-widget-content' >
					


				</div>

		</div>

			<script id='tmplTr' type='text/x-jquery-tmpl'>

			<table style='width:100%;'>

				<tbody>
								
					{{each rows }}			
							{{if Seq == 0}}

							<tr>
								<th>
									&nbsp;
								</th>
								<th>
									{{html FundName}}
								</th>
								<th>
									{{html FundCode}}
								</th>
								<th>
									{{html MStarRating}}
								</th>
								<th>
									{{html MstarCategory}}
								</th>
								<th>
									{{html MstarYTDReturn}}
								</th>
								<th>
									{{html LastClose}}
								</th>
								<th>
									{{html LastPriceDate}}
								</th>
							</tr>

					{{else}}

							<tr class='ui-state-default' 
								onmouseover="$(this).addClass('ui-state-hover')" 
								onmouseout="$(this).removeClass('ui-state-hover')">
								<td>
									{{html FundCheckbox}}
								</td>
								<td>
									{{html FundName}}
								</td>
								<td>
									{{html FundCode}}
								</td>
								<td>
									{{html MStarRating}}
								</td>
								<td>
									{{html MstarCategory}}
								</td>
								<td>
									{{html MstarYTDReturn}}
								</td>
								<td>
									{{html LastClose}}
								</td>
								<td>
									{{html LastPriceDate}}
								</td>
							</tr>

					{{/if}}

					{{/each}}
				</tbody>


			</table>

			</script>

			<script id='tmplConsole' type='text/x-jquery-tmpl'>
			
				<div class='ui-widget-header ui-helper-clearfix' style='padding-top:10px; padding-bottom:10px;'>
				
						<div class='l compare'>
							<a href='javascript:void(0)' title="Compare Funds (up to 5 funds)" onclick="PostMenuAction('FundCompare');">Compare</a>
						</div>
					

					
						<div class='l portfolio'>
							<a href='javascript:void(0)' title="Add To My Portfolio" onclick="PostMenuAction('AddToPortfolio');">Add To My Portfolio</a>
						</div>

					

					
						<div class='l xray'>
							<a href='javascript:void(0)' title="X-Ray (up to 10 funds)" onclick="PostMenuAction('AddXRay');">X-Ray</a>
						</div>
						
					

					
						<div class='l deselect'>
							<a href='javascript:void(0)' title="Deselect All" onclick="PostMenuAction('DeselectAll');">Deselect All</a>
						</div>
				</div>
			
			</script>


			<script id='tmplBox' type='text/x-jquery-tmpl'>

				<div style='float:left'>
					
					{{html FundName}}

				</div>

			</script>

			<script type='text/javascript'>

				var ms_screener = {};
				ms_screener.filter = function (src, proxy) {

					$(proxy).click(function () {

						$(src).click();

					});

				};

				var ms_engine = { helper: {}, template: {} };
				
				
				ms_engine.helper.clearTextFirst = function clearTextFirst(textbox, defaultText) {
					var key = 'ms_textbox_count_click';
					var data = $(textbox).data(key);
					if (typeof data === 'undefined' && $(textbox).val() == defaultText) {
						data = 0;
						$(textbox).val('');
					}
					$(textbox).data(key, data++);
				};

				//render table
				ms_engine.template.mainTable = function (src, proxy) {

					var sourceId = '#' + $(src).attr('id');
					//'#ctl00_ContentPlaceHolder1_aFundScreenerResultControl_gridResult';
					var tmplTr = $('#tmplTr');

					var ms_data = $.map($(sourceId).find('tr').toArray(), function (n, i) {

						if (i == 0) {
							return {
								Seq: i,
								FundName: $(n).find('#colLegalName').html(),
								FundCheckbox: null,
								FundCode: $(n).find('#colFundCode').html(),
								MStarRating: $(n).find('#colStarRatingM255').html(),
								MstarCategory: $(n).find('#colCategoryName').html(),
								MstarYTDReturn: $(n).find('#colReturnM0').html(),
								LastClose: $(n).find('#colClosePrice').html(),
								LastPriceDate: $(n).find('#colClosePriceDate').html()
							};
						}
						else {

							var temp = $(n).find('.gridCheckbox').html();
							$(n).find('.gridCheckbox').remove();

							return {
								Seq: i,
								FundName: $(n).find('.gridFundName').html(),
								FundCheckbox: temp,
								FundCode: $(n).find('.gridFundCode').html(),
								MStarRating: $(n).find('.gridStarRating').html(),
								MstarCategory: $(n).find('.gridCategoryName').html(),
								MstarYTDReturn: $(n).find('.gridYTD').html(),
								LastClose: $(n).find('.gridClosePrice').html(),
								LastPriceDate: $(n).find('.gridPriceDate').html()
							};
						}


					});

					//Assign templates


					tmplTr.tmpl({ 'rows': ms_data }).appendTo('#proxyTabSnapshot');


					//radio
					$("#radioset,#Div1").buttonset();

				};

			
			</script>
			
		

<script type="text/javascript">

	(function () {

		//add console
		$('#tmplConsole').tmpl({}).appendTo('#proxyTabSnapshot');
		$('#tmplConsole').tmpl({}).appendTo('#proxyTabShortTerm');
		$('#tmplConsole').tmpl({}).appendTo('#proxyTabPerformance');
		$('#tmplConsole').tmpl({}).appendTo('#proxyTabPortfolio');
		$('#tmplConsole').tmpl({}).appendTo('#proxyTabFeesAndDetails');


		//link proxy
		var proxy = $('#proxyTabSnapshot,#btnProxyFilter,#ddlProxyFundCompany,#ddlProxyAIMCBoard,#ddlProxyFundType,#txtProxyFundname,#ddlProxyUniverse').ms_uiproxy();
		proxy.link();


		//enhance click checker

		$('#txtProxyFundname').click(function (e) {
			var expectedText = 'Enter name,  ISIN or ticker';
			ms_engine.helper.clearTextFirst(this, expectedText);
		});

		$('#ddlAdvYTD,#ddlAdv1Yr,#ddlAdv3Yr,#ddlAdv5Yr,#ddlAdv10Yr').change(function () {
			var jCtrl = $($(this).attr('match_ctrl'));
			if ($(this).val() == '') {
				jCtrl.prop('disabled', true);
			}
			else {
				jCtrl.prop('disabled', false);
			}
		});


		

		function popAdvQuery() {

			var queries = [

				{ key: 'Company', value: '' }, //Company=0C00001P3H
				{key: 'CategoryType', value: '' }, //CategoryType=0
				{key: 'IncOrAcc', value: '' }, //IncOrAcc=0%7c0%7c1
				{key: 'Category', value: '' },
				{ key: 'FundOfFunds', value: '' }, //FundOfFunds=0%7c0%7c1
				{key: 'Rating', value: '' }, //Rating=1%7c1%7c1%7c1%7c1
				{key: 'Risk', value: '' }, //Risk=1%7c0%7c0%7c0%7c0
				{key: 'StdDeviation', value: '' }, //StdDeviation=1%7c1%7c1
				{key: 'Return', value: '' },
			//Return=Return=10%7cNULL%7cNULL%7cNULL%7c20%7c30%7c40%7c50
			//CategoryReturn=0%7c0%7c0%7c0%7c0%7c1%7c0%7c0
				{key: 'CategoryReturn', value: '' },
				{ key: 'Purchase', value: '' }, //Purchase=2000
				{key: 'Ratio', value: '' }, //Ratio=1.5
				{key: 'InitialSalesCharge', value: ''}//InitialSalesCharge=7.5

			];

			var selectedCompany = $('#ddlAdvCompany').val();
			var selectedCategoryType = $('#ddlAdvCategoryType').val();
			var selectedIncOrAcc = $('input[name="rbInOrAcc"]:checked').val();
			var selectedFundOfFunds = $('input[name="rbFundOfFunds"]:checked').val();
			var selectedCategory = $('#ddlAdvCategory').val();
			var selectedRating = $('#cbAdvRating1,#cbAdvRating2,#cbAdvRating3,#cbAdvRating4,#cbAdvRating5').toArray().map(function (n, i) {
				return $(n).is(':checked') ? '1' : '0';
			}).join('|');
			var selectedRisk = $('#cbAdvRisk1,#cbAdvRisk2,#cbAdvRisk3,#cbAdvRisk4,#cbAdvRisk5').toArray().map(function (n, i) {
				return $(n).is(':checked') ? '1' : '0';
			}).join('|');
			var selectedStdDeviation = $('#cbAdvRisk1,#cbAdvRisk2,#cbAdvRisk3,#cbAdvRisk4,#cbAdvRisk5').toArray().map(function (n, i) {
				return $(n).is(':checked') ? '1' : '0';
			}).join('|');
			var selectedRisk = $('#rbAdvStdDeviation1,#rbAdvStdDeviation2,#rbAdvStdDeviation3').toArray().map(function (n, i) {
				return $(n).is(':checked') ? '1' : '0';
			}).join('|');
			var selectedReturn = (function () {

				if ($('#ddlAdvYTD,#ddlAdv1Yr,#ddlAdv3Yr,#ddlAdv5Yr,#ddlAdv10Yr').filter(function (i, n) { return $(n).val() == 'SpecificValue' }).length > 0) {

					var cTemp = [
					$('#ddlAdvYTD')[0],
					null,
					null,
					null,
					$('#ddlAdv1Yr')[0],
					$('#ddlAdv3Yr')[0],
					$('#ddlAdv5Yr')[0],
					$('#ddlAdv10Yr')[0],
				];

					return $.map(cTemp, function (n) {

						if (n == null) {
							return 'NULL';
						}
						else {
							return $($(n).attr('match_ctrl')).val();
						}

					}).join('|');

				}
				else {
					return '';
				}

			})();
			var selectedCategoryReturn = (function () {

				if ($('#ddlAdvYTD,#ddlAdv1Yr,#ddlAdv3Yr,#ddlAdv5Yr,#ddlAdv10Yr').filter(function (i, n) { return $(n).val() == 'CatAvg' }).length > 0) {
					return decodeURI('0%7c0%7c0%7c0%7c0%7c1%7c0%7c0');
				}
				else {
					return '';
				}

			})();

			var parameters = $(queries).map(function (i, n) {


				if (n.key == 'Company' && selectedCompany != '') {

					n.value = selectedCompany;
				}
				else if (n.key == 'CategoryType' && selectedCategoryType != '') {

					n.value = selectedCategoryType;
				}
				else if (n.key == 'IncOrAcc' && selectedIncOrAcc != '1|0|0') {

					n.value = selectedIncOrAcc;
				}
				else if (n.key == 'Category' && selectedCategory != '') {

					n.value = selectedCategory;
				}
				else if (n.key == 'FundOfFunds' && selectedFundOfFunds != '1|0|0') {

					n.value = selectedFundOfFunds;
				}
				else if (n.key == 'Rating' && selectedRating.indexOf('1') > -1) {

					n.value = selectedRating;
				}
				else if (n.key == 'Risk' && selectedStdDeviation.indexOf('1') > -1) {

					n.value = selectedStdDeviation;
				}
				else if (n.key == 'StdDeviation' && selectedRisk.indexOf('1') > -1) {

					n.value = selectedRisk;
				}
				else if (n.key == 'Return' && selectedReturn != '') {

					n.value = selectedReturn;
				}
				else if (n.key == 'CategoryReturn' && selectedCategoryReturn != '') {

					n.value = selectedCategoryReturn;
				}
				//				else if (n.key == 'Purchase' && $('#').val() != '') {

				//					n.value = null;
				//				}
				//				else if (n.key == 'Ratio' && $('#').val() != '') {

				//					n.value = null;
				//				}
				//				else if (n.key == 'InitialSalesCharge' && $('#').val() != '') {

				//					n.value = null;
				//				}

				if (n.value != null || n.value != '') {
					return encodeURI(n.key) + '=' + encodeURI(n.value);
				}
				else {
					return '';
				}
			});


			var queryString = parameters.filter(function (i, n) { return n != ''; }).toArray().join('&');


			//reload url with generated querystring.
			window.location = window.location.pathname + '?' + queryString + '&tab=tabs-2';

		}


		function switchTab(e, ui) {

		}

		$('#example,#proxyRsTab').tabs({

			select: switchTab

		});

		$("#radA").buttonset();
		$("#radB").buttonset();
		$("#dvProxyFundType").accordion();
		$("#dvProxyFundPerformanceRisk").accordion();

		///Startup
		$(document).ready(function () {


			$('#btnAdvFilter').click(popAdvQuery);

			//Open advance tab
			if (window.location.search.indexOf('tab=tabs-2') > -1) {
				$('a[href="#tabs-2"]').click();
			}


		});

	} ());

</script>


	
 

</asp:Content>
